﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using NCI.EasyObjects;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using CMS.BLL.Entity;
using CMS.DAL;

namespace CMS.BLL
{
    public class HotelPopularDescription
    {
        #region
        public eHotelPopularDescription Data;
        public HotelPopularDescription()
        {
            Data = new eHotelPopularDescription();
        }
        ~HotelPopularDescription()
        {
        }
        public virtual void Dispose()
        {
        }
        public int DeleteById(int ID)
        {
            int nResult = 0;
            cHotelPopularDescription objDAL = new cHotelPopularDescription();
            try
            {
                objDAL.LoadByPrimaryKey(ID);
                objDAL.MarkAsDeleted();
                objDAL.Save();
                nResult = ID;
            }
            catch
            {
                nResult = 0;
            }
            return nResult;
        }
        public void LoadById(int ID)
        {
            cHotelPopularDescription objDAL = new cHotelPopularDescription();
            objDAL.LoadByPrimaryKey(ID);
            ConvertData(objDAL);
        }
        public DataTable GetAll()
        {
            DataTable tbResult = new DataTable();
            cHotelPopularDescription objDAL = new cHotelPopularDescription();
            tbResult = objDAL.GetAll();
            return tbResult;
        }
        public int Insert()
        {
            int nResult = 0;
            cHotelPopularDescription objInfor = new cHotelPopularDescription();
            try
            {
                objInfor.AddNew();
                this.MappingData(objInfor);
                objInfor.Save();
                nResult = objInfor.HotelID;
            }
            catch
            {
                nResult = 0;
            }
            return nResult;
        }

        public int Update(int ID)
        {
            int nResult = 0;
            cHotelPopularDescription objInfor = new cHotelPopularDescription();
            try
            {
                objInfor.LoadByPrimaryKey(ID);
                this.MappingData(objInfor);
                objInfor.Save();
                nResult = ID;
            }
            catch
            {
                nResult = 0;
            }
            return nResult;
        }
        
        private void MappingData(cHotelPopularDescription objInfor)
        {
            objInfor.HotelID = Data.HotelID;
            objInfor.HotelPopularID = Data.HotelPopularID;
        }
        private void ConvertData(cHotelPopularDescription objInfor)
        {
            Data.HotelID = objInfor.HotelID;
            Data.HotelPopularID = objInfor.HotelPopularID;
        }
        public DataTable Search(int ItemID, int ItemView, int DefaultLangId, int CurrentLangId, int PageIndex, int PageSize, ref int PageCount)
        {
            DataTable tbResult = new DataTable();
            cHotelPopularDescription objDAL = new cHotelPopularDescription();
            tbResult = objDAL.Search(ItemID, ItemView, DefaultLangId, CurrentLangId, PageIndex, PageSize, ref PageCount);
            return tbResult;
        }
        public DataTable SearchByHotelID(int ItemID)
        {
            DataTable tbResult = new DataTable();
            cHotelPopularDescription objDAL = new cHotelPopularDescription();
            tbResult = objDAL.SearchByHotelID(ItemID);
            return tbResult;
        }
        public int DeleteByHotelID(int HotelID)
        {
            int nResult = 0;
            cHotelPopularDescription objInfor = new cHotelPopularDescription();
            try
            {
                nResult = objInfor.DeleteByHotelID(HotelID);
            }
            catch
            {
                nResult = 0;
            }
            return nResult;
        }
        #endregion
    }
}
        